﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;

namespace WebApplication1
{
    public partial class SendMailModule : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public bool sendMail(string from, string to, string subject, string body, string host, int port)
        {
            System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.From = new System.Net.Mail.MailAddress(from.ToString());
            mail.To.Add(new MailAddress(to.ToString()));
            mail.SubjectEncoding = System.Text.Encoding.GetEncoding("iso-8859-1");
            mail.Subject = subject.ToString();
            mail.BodyEncoding = System.Text.Encoding.GetEncoding("iso-8859-1");
            mail.Body = body.ToString();
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
            smtp.Host = host.ToString();
            smtp.Port = port;
            //              smtp.Credentials = new System.Net.NetworkCredential(login.ToString(), pass.ToString());
            try
            {
                smtp.Send(mail);
                return true;
            }

            catch (Exception E)
            {
                return false;
            }

        }
    }
}